/*
 * @copyright   Copyright (C) 2010-2021 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */

/* SCSS variables */
$ibo-quick-create--head--background-color: $ibo-color-white-100 !default;

$ibo-quick-create--icon-padding-x: 16px !default;
$ibo-quick-create--icon-padding-y: 0 !default;

$ibo-quick-create--input--padding: 0 default;
$ibo-quick-create--input--padding-x--is-opened: 8px !default;
$ibo-quick-create--input--padding-y--is-opened: 8px !default;
$ibo-quick-create--input--width: 0 !default;
$ibo-quick-create--input--width--is-opened: 245px !default;
$ibo-quick-create--input--text-color: $ibo-color-grey-800 !default;
$ibo-quick-create--input--placeholder-color: $ibo-color-grey-600 !default;

$ibo-quick-create--input-options--background-color: $ibo-quick-create--head--background-color !default;
$ibo-quick-create--input-options--border: none !default;
$ibo-quick-create--input-options--border-radius: 0 !default;

$ibo-quick-create--drawer--max-height: 300px !default;
$ibo-quick-create--drawer--padding-x: $ibo-quick-create--icon-padding-x !default;
$ibo-quick-create--drawer--padding-y: 16px !default;
$ibo-quick-create--drawer--top: -1 * ($ibo-quick-create--drawer--max-height) - 10 !default; /* 10px of margin to avoid to be slightly visible when closed and has a lot of history */
$ibo-quick-create--drawer--top--is-opened: 100% !default;
$ibo-quick-create--drawer--background-color: $ibo-color-white-100 !default;

$ibo-quick-create--compartment-title--margin-top: 8px !default;
$ibo-quick-create--compartment-title--margin-bottom: $ibo-quick-create--compartment-title--margin-top !default;
$ibo-quick-create--compartment-title--padding-left: 32px !default;
$ibo-quick-create--compartment-title--text-color: $ibo-color-grey-800 !default;
$ibo-quick-create--compartment-title--line-spacing: 8px !default;

$ibo-quick-create--compartment-content--text-color: $ibo-color-grey-900 !default;

$ibo-quick-create--compartment-element--padding-x: 8px !default;
$ibo-quick-create--compartment-element--padding-y: 4px !default;
$ibo-quick-create--compartment-element--margin-x: -1 * $ibo-quick-create--compartment-element--padding-x !default;
$ibo-quick-create--compartment-element--background-color--is-active: $ibo-color-grey-200 !default;
$ibo-quick-create--compartment-element--border-radius--is-active: $ibo-border-radius-300 !default;

$ibo-quick-create--compartment-element-image--margin-right: 8px !default;
$ibo-quick-create--compartment-element-image--width: 20px !default;

$ibo-quick-create--compartment-results--container--width: 100% !important !default;

$ibo-quick-create--compartment--placeholder-image--margin-top: 24px !default;
$ibo-quick-create--compartment--placeholder-image--margin-bottom: 16px !default;
$ibo-quick-create--compartment--placeholder-image--margin-x: auto !default;
$ibo-quick-create--compartment--placeholder-image--width: 66% !default;

$ibo-quick-create--compartment--placeholder-hint--padding-x: 8px !default;
$ibo-quick-create--compartment--placeholder-hint--padding-y: 0 !default;
$ibo-quick-create--compartment--placeholder-hint--text-color: $ibo-color-grey-700 !default;

/* Animations*/
@keyframes ibo-quick-create--drawer--opening{
	from {
		top: $ibo-quick-create--drawer--top;
		box-shadow: none;
	}
	to {
		top: $ibo-quick-create--drawer--top--is-opened;
		box-shadow: $ibo-elevation-300;
	}
}

/* SCSS rules */
.ibo-quick-create{
	position: relative;
	@extend %ibo-full-height-content;

	&.ibo-is-opened{
		.ibo-quick-create--input{
			width: $ibo-quick-create--input--width--is-opened;
		}
		.ibo-quick-create--drawer{
			animation-name: ibo-quick-create--drawer--opening;
			animation-delay: 0.1s;
			animation-duration: 0.2s;
			animation-direction: normal;
			animation-fill-mode: forwards;
		}
	}
}
.ibo-quick-create--head{
	@extend %ibo-full-height-content;
	background-color: $ibo-quick-create--head--background-color;
}
.ibo-quick-create--icon{
	align-self: center;
	padding: $ibo-quick-create--icon-padding-y $ibo-quick-create--icon-padding-x;
	@extend %ibo-font-ral-nor-400;
}
.ibo-quick-create--input{
	width: $ibo-quick-create--input--width;
	border: none;
	transition: all 0.2s ease-in-out;

	/* Remove selectize.js theme and apply our own */
	&.selectize-control.single{
		position: sticky;
		display: flex;

		.selectize-input{
			display: flex;
			background-color: transparent;
			background-image: none;
			border: none;
			box-shadow: none;

			&.input-active{
				@extend .selectize-input;
			}

			> input{
				color: $ibo-quick-create--input--text-color;
				@extend %ibo-font-ral-nor-300;

				outline: none;
				border: none;

				&::placeholder{
					color: $ibo-quick-create--input--placeholder-color;
				}
				/* This rule is duplicated otherwise Chrome won't be able to parse it. */
				&:-ms-input-placeholder,
				&::-ms-input-placeholder{
					color: $ibo-quick-create--input--placeholder-color;
				}
			}
			> .item{
				color: $ibo-quick-create--input--text-color;
				@extend %ibo-font-ral-nor-300;
				
				line-height: 200%;
			}
		}
		.selectize-dropdown{
			background-color: $ibo-quick-create--input-options--background-color;
			border: $ibo-quick-create--input-options--border;
			border-radius: $ibo-quick-create--input-options--border-radius;
			@extend %ibo-elevation-300;
		}
	}
}
/* TODO: Make drawer appear below the top bar so its shadow is cast on the drawer */
.ibo-quick-create--drawer{
	z-index: -1;
	position: absolute;
	left: 0;
	right: 0;
	top: $ibo-quick-create--drawer--top;
	padding: $ibo-quick-create--drawer--padding-y $ibo-quick-create--drawer--padding-x;
	background-color: $ibo-quick-create--drawer--background-color;
	box-shadow: none;
	@extend %ibo-font-size-100;
}
.ibo-quick-create--compartment-title{
	margin-top: $ibo-quick-create--compartment-title--margin-top;
	margin-bottom: $ibo-quick-create--compartment-title--margin-bottom;
	padding-left: $ibo-quick-create--compartment-title--padding-left;
	overflow-x: hidden;
	color: $ibo-quick-create--compartment-title--text-color;

	> span{
		position: relative;

		&::before,
		&::after{
			content: "";
			display: inline-block;
			position: absolute;
			top: 50%;
			height: 1px;
			width: 600px;
			border-top: 1px solid $ibo-quick-create--compartment-title--text-color;
		}
		&::before{
			right: 100%;
			margin-right: $ibo-quick-create--compartment-title--line-spacing;
		}
		&::after{
			left: 100%;
			margin-left: $ibo-quick-create--compartment-title--line-spacing;
		}
	}
}
.ibo-quick-create--compartment-content{
	color: $ibo-quick-create--compartment-content--text-color;
}
.ibo-quick-create--compartment-element{
	display: flex;
	align-items: center;
	padding: $ibo-quick-create--compartment-element--padding-y $ibo-quick-create--compartment-element--padding-x;
	margin-left: $ibo-quick-create--compartment-element--margin-x;
	margin-right: $ibo-quick-create--compartment-element--margin-x;
	color: inherit;

	@extend %ibo-text-truncated-with-ellipsis;
}
.ibo-quick-create--compartment-element-image{
	margin-right: $ibo-quick-create--compartment-element-image--margin-right;
	width: $ibo-quick-create--compartment-element-image--width;
}

.ibo-quick-create--compartment-results--container{
	width: $ibo-quick-create--compartment-results--container--width;
}
.ibo-quick-create--compartment-results--element > .option{
	padding: $ibo-quick-create--compartment-element--padding-y $ibo-quick-create--compartment-element--padding-x;
	margin-left: $ibo-quick-create--compartment-element--margin-x;
	margin-right: $ibo-quick-create--compartment-element--margin-x;
	color: inherit;

	@extend %ibo-text-truncated-with-ellipsis;

	&.active{
		background-color: $ibo-quick-create--compartment-element--background-color--is-active;
		border-radius: $ibo-quick-create--compartment-element--border-radius--is-active;
	}
	&:hover{
		cursor: pointer;
		@extend a:hover;
	}

	.highlight{
		font-weight: bold;
	}
}

.ibo-quick-create--compartment--placeholder{
	align-items: center;
	display: flex;
	flex-direction: column;
}
.ibo-quick-create--compartment--placeholder-image>svg{
	width: $ibo-quick-create--compartment--placeholder-image--width;
	height: inherit;
	margin: $ibo-quick-create--compartment--placeholder-image--margin-top $ibo-quick-create--compartment--placeholder-image--margin-x $ibo-quick-create--compartment--placeholder-image--margin-bottom $ibo-quick-create--compartment--placeholder-image--margin-x;
	display: flex;
}
.ibo-quick-create--compartment--placeholder-hint{
	text-align: justify;
	padding: $ibo-quick-create--compartment--placeholder-hint--padding-y $ibo-quick-create--compartment--placeholder-hint--padding-x;
	color: $ibo-quick-create--compartment--placeholder-hint--text-color;
	@extend %ibo-font-ral-ita-100;
}